<template>
  <view class="yh-page">
	<view class="page">
	  <view class="uni-column">
		<view class="yh-title">
			微信web登录授权
		</view>
	  	<view class="uni-btn-v">
	  		<button type="default" @tap="handleToWechatTestAuth()">微信web登录授权(仅限微信公众号下)</button>
	  	</view>
	  </view>
	  <view class="uni-column">
	  	<view class="yh-title">
	  		微信支付测试
	  	</view>
	  	<view class="uni-btn-v">
	  		<button type="default" @tap="handleToWechatTestPay()">微信支付(仅限微信公众号下)</button>
	  	</view>
	  </view>
	  <view class="uni-column">
	  	<view class="yh-title">
	  		登录退出测试
	  	</view>
	  	<view class="uni-btn-v">
	  		<button type="default" @tap="handleToLoginAndLogOut()">登录退出测试</button>
	  	</view>
	  </view>
	  <view class="uni-column">
	  	<view class="yh-title">
	  		测试websocket
	  	</view>
	  	<view class="uni-btn-v">
	  		<button type="default" @tap="handleToWebsocketTest()">测试websocket</button>
	  	</view>
	  </view>
	  <view class="uni-column">
	  	<view class="yh-title">
	  		测试后台消息通知
	  	</view>
	  	<view class="uni-btn-v">
	  		<button type="default" @tap="handleToAdminSocketTest()">测试后台消息通知</button>
	  	</view>
	  </view>
	  <view class="uni-column">
	  	<view class="yh-title">
	  		测试图片上传
	  	</view>
	  	<view class="uni-btn-v">
	  		<button type="default" @tap="handleToUplaodPcitureTest()">测试图片上传</button>
	  	</view>
	  </view>
	  <view class="uni-column">
	  	<view class="yh-title">
	  		定位测试
	  	</view>
	  	<view class="uni-btn-v">
	  		<button type="default" @tap="handleToGetLocationTest()">定位测试</button>
	  	</view>
	  </view>
	 </view>
  	</view>
</template>

<script>
import { test } from '@/api/test';
import { isWechat }  from '@/utils/wechat';
export default 
{
	//计算属性
	computed:
	{
	},
	//监听
	watch:
	{
	},
	data() 
	{
		return{
			//是否在微信环境下
			isWechat:false
		};
	},
	//页面加载
	onLoad() 
	{
		//this.test()
		this.isWechat = isWechat()
	},
	//页面显示
	onShow() 
	{

	},
	//页面初次渲染完成
	onReady()
	{

	},
	//页面隐藏
	onHide()
	{

	},
	//页面卸载
	onUnload()
	{

	},
	methods:
	{
		//测试接口
		async test() {
			console.log('here')
			const result = await test();
			console.log(result);
		},
		//跳转到微信测试页面
		handleToWechatTestAuth()
		{
			if(!this.isWechat)
			{
				uni.showToast({
					image: "/static/test/notice/03-warning.png",
					title: "不在微信",
					mask:true,
					duration:2000
				})
				
				return 
			}
			
			uni.switchTab({
				url:'/pages/Test/V1/tabBar/wechat-auth/wechat-auth'
			})
		},
		//测试微信支付
		handleToWechatTestPay()
		{
			if(!this.isWechat)
			{
				uni.showToast({
					image: "/static/test/notice/03-warning.png",
					title: "不在微信",
					mask:true,
					duration:2000
				})
				
				return 
			}
			
			uni.switchTab({
				url:'/pages/Test/V1/tabBar/wechat-pay/wechat-pay'
			})
			
		},
		//测试退出
		handleToLoginAndLogOut()
		{
			uni.navigateTo({
				url:'/pages/Test/V1/login/login-total/login-total'
			})
		},
		//测试websocket
		handleToWebsocketTest()
		{
			uni.navigateTo({
				url:'/pages/Test/V1/socket/websocket/websocket'
			})
		},
		//测试后台消息通知
		handleToAdminSocketTest()
		{
			uni.navigateTo({
				url:'/pages/Test/V1/socket/adminsocket/adminsocket'
			})
		},
		//测试图片上传
		handleToUplaodPcitureTest()
		{
			uni.navigateTo({
				url:'/pages/Test/V1/upload/upload-picture/upload-picture'
			})
		},
		//定位测试
		handleToGetLocationTest()
		{
			uni.navigateTo({
				url:'/pages/Test/V1/location/web-get-location/web-get-location'
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.page{
	width:calc(100% - 70rpx);
	padding:35rpx;
}
</style>
